import request from "@/utils/request";
// 请求短信验证码API
export const getMobileCodeAPI = (mobile) => {
  return request.get(`/sms/codes/${mobile}/`);
};

// 登录API
export const loginAPI = (mobile, code, update = false) => {
  return request.post("/authorizations/", {
    mobile,
    code,
    update,
  });
};

// 刷新tokenAPI
export const refreshTokenAPI = (refresh_token) => {
  return request.post("/refreshtoken/", {
    refresh_token,
  });
};

// 获取用户名数量
export const usernameCountAPI = (username) => {
  return request.get(`/username/${username}/`);
};

// 用户信息
export const profileAPI = (id) => {
  return request.get(`/profile/${id}/`);
};

// 修改用户信息
export const updateProfileAPI = (id, profile) => {
  return request.put(`/profile/${id}/`, profile);
};

// 上传头像
export const uploadAvatarAPI = (fd) => {
  return request.post("avatar/", fd);
};

// 申请教师认证
export const beTeacherAPI = (form) => {
  return request.post("teacher/", form);
};

// 获取教师信息
export const teacherAPI = (user_id) => {
  return request.get(`teacher/${user_id}/`);
};

// 修改教师信息
export const updateTeacherAPI = (form) => {
  return request.put(`teacher/${form.id}/`, form);
};

// 请求老师列表信息
export const initTeacherListAPI = (page) => {
  return request.get(`teacher/?page=${page}`);
};

// 省
export const provinceListAPI = () => {
  return request.get("areas/");
};

// 市
export const cityListAPI = (id) => {
  return request.get(`areas/${id}/`);
};

// 教师详情页发布评论
export const pubCommentAPI = (comment) => {
  return request.post("tcomments/", comment);
};

// 教师详情页获取评论
export const commentListAPI = (teacher_id, page) => {
  return request.get(`tcomments/?page=${page}&teacher_id=${teacher_id}`);
};

// 对老师点赞
export const likeTeacherAPI = (target) => {
  return request.post(`tlike/${target}/`);
};

// 对老师取消点赞
export const dislikeTeacherAPI = (target) => {
  return request.delete(`tlike/${target}/`);
};

// 关注老师
export const followTeacherAPI = (target) => {
  return request.post(`tfollow/${target}/`);
};

// 取消关注老师
export const unfollowTeacherAPI = (target) => {
  return request.delete(`tfollow/${target}/`);
};

// 关注老师
export const followUserAPI = (target) => {
  return request.post(`ufollow/${target}/`);
};

// 取消关注老师
export const unfollowUserAPI = (target) => {
  return request.delete(`ufollow/${target}/`);
};

// 获取用户粉丝列表
export const userFansAPI = (user_id, page) => {
  return request.get(`users/fans/${user_id}/?page=${page}`);
};

// 获取用户关注列表
export const userFollowingsAPI = (user_id, page) => {
  return request.get(`users/followings/${user_id}/?page=${page}`);
};

// 获取用户关注列表
export const userCollectionsAPI = (user_id, page) => {
  return request.get(`users/collections/${user_id}/?page=${page}`);
};

// 最近聊天
export const chatRecentAPI = (page) => {
  return request.get(`chat/recent/?page=${page}`);
}

// 聊天记录
export const chatHistoryAPI = (target, page) => {
  return request.get(`chat/history/${target}/?page=${page}`);
}

// 系统通知
export const SysMessageAPI = (page) => {
  return request.get(`chat/system/?page=${page}`);
}

// 未读系统通知数量
export const unreadSysMsgCountAPI= ()=> {
  return request.get("chat/system/count");
}